package com.dragon.backstage.domain.param.role;

import com.dragon.common.utils.AjaxResult;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;
import java.util.Objects;

/**
 * 角色模块-授权用户批量添加请求参数
 *
 * @author dragon
 * @version 1.0
 * @date 2024/8/7 17:18
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "角色模块-授权用户批量添加请求参数")
public class RoleAuthUserAddBatchParam {

    /**
     * 角色ID
     */
    @Schema(title = "角色ID", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long roleId;

    /**
     * 用户ID列表
     */
    @Schema(title = "用户ID列表", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<Long> userIds;


    /**
     * 参数校验
     */
    public static AjaxResult<Void> check(RoleAuthUserAddBatchParam param) {
        if (Objects.isNull(param)) {
            return AjaxResult.failed("请求参数不能为空");
        }
        if (Objects.isNull(param.getRoleId()) || param.getRoleId() < 1L) {
            return AjaxResult.failed("角色ID不能为空");
        }
        if (CollectionUtils.isEmpty(param.getUserIds())) {
            return AjaxResult.failed("用户ID列表不能为空");
        }

        return AjaxResult.succeed();
    }

}
